var regDate=/^([1-9]{1}[d]{3})-([d]{2})-([0-4]{1}[d]{1})$/ // 年份
var regTime=/^([d]{2}):([d]{2}):([d]{2})$/;// 时间
var regTel=/^(0[d]{2,3}[-])?([d]{2,3}[-])?([d]{7,8})$/;// 常用的电话

function addfavorite()
{
   if (document.all)
   {
      window.external.addFavorite('http://user.etong-online.com','医通在线-用户预约平台');
   }
   else if (window.sidebar)
   {
      window.sidebar.addPanel('收藏我们', 'http://user.etong-online.com', "");
   }
} 


function SetHome(obj,vrl){
        try{
                obj.style.behavior='url(#default#homepage)';obj.setHomePage(vrl);
        }
        catch(e){
                if(window.netscape) {
                        try {
                                netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
                        }
                        catch (e) {
                                alert("此操作被浏览器拒绝！\n请在浏览器地址栏输入“about:config”并回车\n然后将 [signed.applets.codebase_principal_support]的值设置为'true',双击即可。");
                        }
                        var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
                        prefs.setCharPref('browser.startup.homepage',vrl);
                 }
        }
}


function delconfirm() {
confirm('Are You Sure Delete');
}
function check(field,div)
	{
		var str=document.getElementById(field).value;
		str   =   str.replace(/^\s+|\s+$/g,"");   // 去掉空格
	var userCheck=str;
	var divcheck=document.getElementById(div);
	var bnt=document.getElementById('btnSubmit');

			if(userCheck==""||userCheck==null)
		{
			 document.getElementById(field).className='nbt';
			 divcheck.innerHTML=" <font color=red>Empty</font>";
			 bnt.disabled=true;
		 }else{
			 document.getElementById(field).className='';
			 divcheck.innerHTML="<img src=templates/admin/images/checked.gif width=14 height=14>";
		      bnt.disabled=false;
}
	
	}


    // 检查是否非空
    function notEmpty(obj, msg)
    {
        str = obj.value;
        str1 = "";
        for (i = 0; i < str.length; i++)
        {
                if (str.charAt(i) != " ")
                {
                    str1 = str.substr(i, str.length);
                    break;
                }
        }
    
        if (str1 == "")
        {
            alert(msg);
            obj.value = "";
            obj.focus();
            return false;
        }
        else
        {
            return true;
        }
    }
    
    // 检查是否为数字
function fucCheckNUM(NUM) 
{ 
var i,j,strTemp; 
strTemp="0123456789"; 
if ( NUM.length== 0) 
return 0 
for (i=0;i<NUM.length;i++) 
{ 
j=strTemp.indexOf(NUM.charAt(i)); 
if (j==-1) 
{ 
// 说明有字符不是数字
return false; 
} 
} 
// 说明是数字
return true; 
} 
    // 检查密码是否相同
    function isSamePwd(objPwd1, objPwd2, msg)
    {
        pwd1 = objPwd1.value;
        pwd2 = objPwd2.value;
    
        if (pwd1 != pwd2)
        {
        if (null == msg)
        {
            alert("密码不相同！");
         }
         else
         {
             alert(msg);
         }
         
        objPwd2.value = "";
        objPwd2.focus();
        return false;
        }
        else
        {
        return true;
        }
    }
    
    // 检查邮件地址
    function isEmail(obj, msg)
    {
        ch = obj.value;
        if((ch.indexOf("@") < 1) || (ch.indexOf(".") < 1) || (ch.indexOf(".") == ch.length - 1))
        {
        if (null == msg)
        {
            alert("Email Error！");
        }
        else
        {
            alert(msg);
        }
        obj.select();
        return false;
        }
        else
        {
        return true;
        }
    }

		function CheckAll(form){
	for (var i=0;i<form.elements.length;i++){
		var e = form.elements[i];
		e.checked == true ? e.checked = true : e.checked = true;
	}
	}
		function CheckAlls(form){
	for (var i=0;i<form.elements.length;i++){
		var e = form.elements[i];
		e.checked == false ? e.checked = false : e.checked = false;
	}
	}


function isNumber( s ){ 
var regu = "^[0-9]+$"; 
var re = new RegExp(regu); 
if (s.search(re) != -1) { 
return true; 
} else { 
return false; 
} 
} 
function isDate (theStr) {
    
    var dArray=theStr.match(regDate);    // 得到数组
    if (dArray==null){
        return (false);
    }
    else {                                // 把年份月份日期分别付给变量
        var y = dArray[1];
        var m = dArray[2];
        var d = dArray[3];

        var maxDays = 31;               // 最长天数

        if (m>12 || m<1 ) return false;// 判断月份是否在1-12之间
        if (m == 4 || m == 6 || m == 9 || m == 11) maxDays = 30;
        else if(m == 2) {
            if ( y % 4 > 0) maxDays = 28;
            else if ( y % 100 == 0 && y % 400 > 0) maxDays = 28;
            else maxDays = 29;
        }
        if (d>maxDays || d<1){// 判断日期是否正确
            return false;
        }
        else {
            return true;
        }
    }
}

function sAlert(str,urlto,width,height){ 
   var msgw,msgh,bordercolor; 
   msgw=width;//提示窗口的宽度 
   msgh=height;//提示窗口的高度 
   titleheight=25 //提示窗口标题高度 
   bordercolor="#0033FF";//提示窗口的边框颜色 
   titlecolor="#0033FF";//提示窗口的标题颜色 
  
   var sWidth,sHeight; 
   sWidth=document.body.offsetWidth; 
   sHeight=document.body.offsetHeight; 
   var bgObj=document.createElement("div"); 
   bgObj.setAttribute('id','bgDiv'); 
   bgObj.style.position="absolute"; 
   bgObj.style.top="0"; 
   bgObj.style.background="#777"; 
   bgObj.style.filter="progid:DXImageTransform.Microsoft.Alpha(style=3,opacity=25,finishOpacity=75"; 
   bgObj.style.opacity="0.6"; 
   bgObj.style.left="0"; 
   bgObj.style.width=sWidth + "px"; 
   bgObj.style.height=sHeight + "px"; 
   bgObj.style.zIndex = "10000"; 
   document.body.appendChild(bgObj); 
    
   var msgObj=document.createElement("div") 
   msgObj.setAttribute("id","msgDiv"); 
   msgObj.setAttribute("align","center"); 
   msgObj.style.background="white"; 
   msgObj.style.border="1px solid " + bordercolor; 
   msgObj.style.position = "absolute"; 
   msgObj.style.left = "50%"; 
   msgObj.style.top = "50%"; 
   msgObj.style.font="12px/1.6em Verdana, Geneva, Arial, Helvetica, sans-serif"; 
   msgObj.style.marginLeft = "-225px" ; 
   msgObj.style.marginTop = -75+document.documentElement.scrollTop+"px"; 
   msgObj.style.width = msgw + "px"; 
   msgObj.style.height =msgh + "px"; 
   msgObj.style.textAlign = "center"; 
   msgObj.style.lineHeight ="25px"; 
   msgObj.style.zIndex = "10001"; 
    
   var title=document.createElement("h4"); 
   title.setAttribute("id","msgTitle"); 
   title.setAttribute("align","right"); 
   title.style.margin="0"; 
   title.style.padding="3px"; 
   title.style.background=bordercolor; 
   title.style.filter="progid:DXImageTransform.Microsoft.Alpha(startX=20, startY=20, finishX=100, finishY=100,style=1,opacity=75,finishOpacity=100);"; 
   title.style.opacity="0.75"; 
   title.style.border="1px solid " + bordercolor; 
   title.style.height="18px"; 
   title.style.font="12px Verdana, Geneva, Arial, Helvetica, sans-serif"; 
   title.style.color="white"; 
   title.style.cursor="pointer"; 
   title.innerHTML="关闭"; 
   title.onclick=function(){ 
          document.body.removeChild(bgObj); 
          document.getElementById("msgDiv").removeChild(title); 
          document.body.removeChild(msgObj); 
		if(urlto != ''){
			 if(urlto == 'reload'){
				 window.location .reload();
				  }else{
			     window.location =urlto;
				  }
			}
        } 
   document.body.appendChild(msgObj); 
   document.getElementById("msgDiv").appendChild(title); 
   var txt=document.createElement("p"); 
   txt.style.margin="1em 0" 
   txt.setAttribute("id","msgTxt"); 
   txt.innerHTML=str; 
   document.getElementById("msgDiv").appendChild(txt); 
}

function select_t(v){
   if(v == 2){
     $("#ifaccpet_table").hide();
   }else if(v==1){
     $("#ifaccpet_table").show();
   }
   
}